class Solution {
public:
    vector<int> distinctDifferenceArray(vector<int>& nums) {
        int n = nums.size();
        set<int>s;
        vector<int>pre(n), ans(n);
        for (int i = 0; i < n; i++) {
            s.insert(nums[i]);
            pre[i] = s.size();
        }
        s.clear();
        for (int i = n - 1; i >= 0; i--) {
            cout << "pre[i]==" << pre[i] << endl;
            cout << "s.size()==" << s.size() << endl;
            ans[i] = pre[i] - s.size();
            s.insert(nums[i]);
        }
        return ans;
    }
};